<template>
  <div class="account-settings-info-view">
    <a-row :gutter="16" type="flex" justify="center">
      <a-col :md="24" :lg="16">

        <a-form layout="vertical" :form="form">
          <a-form-item label="旧密码">
            <a-input-password size="large" :placeholder="'旧密码'" v-decorator="[
              'password',
              { rules: [{ required: true, message: '请输入旧密码' }], validateTrigger: 'blur' }
            ]">
              <a-icon slot="prefix" type="lock" :style="{ color: 'rgba(0,0,0,.25)' }" />
            </a-input-password>
          </a-form-item>
          <a-form-item label="新密码">
            <a-input-password size="large" :placeholder="'新密码'" v-decorator="[
              'newPassword',
              { rules: [{ required: true, message: '请输入新密码' }], validateTrigger: 'blur' }
            ]">
              <a-icon slot="prefix" type="lock" :style="{ color: 'rgba(0,0,0,.25)' }" />
            </a-input-password>
          </a-form-item>
          <a-form-item>
            <a-button :loading="loading" type="primary" @click="changePassword">确认修改</a-button>
          </a-form-item>
        </a-form>

      </a-col>

    </a-row>

  </div>
</template>

<script>
import AvatarModal from './AvatarModal'
import { baseMixin } from '@/store/app-mixin'
import api from '@/api/user/people'

export default {
  mixins: [baseMixin],
  components: {
    AvatarModal
  },
  data() {
    return {
      // cropper
      preview: {},
      option: {},
      loading: false,
      form: this.$form.createForm(this, {
        userAccount: 'admin',
        password: '',
        newPassword: '',
      })
    }
  },
  methods: {
    changePassword(e) {
      console.log(22222);

      this.form.validateFields((err, values) => {
        if (!err) {
          console.log(values);
          this.loading = true
          values.userAccount = 'admin'
          api.changePassword(values).then(res => {
            console.log(res);
            this.loading = false
            this.$message.success('修改成功');
          }).catch(err => {
            console.log(err);
            this.loading = false
            this.$message.error('修改失败');
          })
        }
      });
      /* const queryParam = { ...values }
       queryParam.userAccount="";
       queryParam.password="";
       queryParam.newPassword="";*/

    },
  }
}
</script>